class MidiasController < ApplicationController
  # GET /midias
  # GET /midias.xml
  def index
    @midias = Midia.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @midias }
      format.amf { render :amf => @midias }
    end
  end

  # GET /midias/1
  # GET /midias/1.xml
  def show
    @midia = Midia.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @midia }
    end
  end

  # GET /midias/new
  # GET /midias/new.xml
  def new
    @midia = Midia.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @midia }
    end
  end

  # GET /midias/1/edit
  def edit
    @midia = Midia.find(params[:id])
  end

  # POST /midias
  # POST /midias.xml
  def create
    @midia = Midia.new(params[:midia])

    respond_to do |format|
      if @midia.save
        flash[:notice] = 'Midia was successfully created.'
        format.html { redirect_to(@midia) }
        format.xml  { render :xml => @midia, :status => :created, :location => @midia }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @midia.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /midias/1
  # PUT /midias/1.xml
  def update
    @midia = Midia.find(params[:id])

    respond_to do |format|
      if @midia.update_attributes(params[:midia])
        flash[:notice] = 'Midia was successfully updated.'
        format.html { redirect_to(@midia) }
        format.xml  { head :ok }
        format.amf  { render :amf => @midia }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @midia.errors, :status => :unprocessable_entity }
        format.xml  { render :amf => FaultObject.new(@pessoa.errors.full_messages.join('\n')) }
      end
    end
  end

  # DELETE /midias/1
  # DELETE /midias/1.xml
  def destroy
    @midia = Midia.find(params[:id])
    @midia.destroy

    respond_to do |format|
      format.html { redirect_to(midias_url) }
      format.xml  { head :ok }
    end
  end
end
